{# empty Twig template #}
{% extends "PyafGymBundle::layout_admin.html.twig" %}

{% block title %} Pyaf {% endblock %}
{% block tituloSector %}<i class="icon-save"></i> BackUp - Gestiona la importación y exportación de la Base de Datos  {% endblock %}
{% block nombreSector %} BackUp {% endblock %}

{% block dashboardContent %}{% endblock %}

{% block content %}
    <div class="container-fluid" id="content-area" style="padding-right: 30px;">    
        
        <div id="mensajero"></div>
        {% if app.session.hasFlash('alertaConfiguracionSuccess') %}
            <div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                {{ app.session.flash('alertaConfiguracionSuccess') }}
            </div>
        {% endif %}
        {% if app.session.hasFlash('alertaConfiguracionError') %}
            <div class="alert alert-error">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                {{ app.session.flash('alertaConfiguracionError') }}
            </div>
        {% endif %}
        
        <div class="row-fluid">
        <div class="span12">
            <div class="box">
                <div class="box-head"><i class="icon-save"></i><span>Gestor de datos</span></div>
                <div class="box-body">
                    <div class="row-fluid">
                        <div class="span12">
                            <div class="mini-layout">
                                <div class="mini-layout-header">
                                    <i class="icon-download-alt"></i>
                                    <span>Exportar base de datos</span>
                                </div>
                                <div class="mini-layout-body">
                                    <div>
                                        <div style="padding: 20px;">
                                            <text id='porciento'>0%</text><span class="pull-right" id="cartel">Por favor aguarde...</span>
                                            <div class="progress progress-striped active">
                                                <div class="bar" style="width: 0%;" data-percentage="25"></div>
                                            </div>
                                            <p class="text-center">
                                                <button onclick="exportDataBase('{{ path('admin_configuracion_save') }}')" class="btn btn-primary submit" type="button" id="btnExportar">Exportar</button>
                                                <button class="btn btn-inverse" type="button" id="btnVolverExportar">Volver a Exportar</button>
                                            </p>
                                            <div id="zip"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                        <div class="span12"><br/></div>    
                    <div class="row-fluid">
                        <div class="span12">
                             <div class="mini-layout">
                                <div class="mini-layout-header">
                                    <i class="icon-upload-alt"></i>
                                    <span>Importar base de datos</span>
                                </div>
                                <div class="">
                                    <div>
                                        <div style="padding: 20px;">
                                            <iframe class="span12" 
                                                    src="{{ path('admin_configuracion_bigdump') }}"
                                                    style="height: 600px; border: 0px;"
                                                    
                                                    >
                                            </iframe>
                                            <div id=""></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>   
</div>
{% endblock %}
{% block javascripts %}
     <script type='text/javascript'>
       $(document).ready(function() {
           
           $('#bigdump').load('{{ path('admin_configuracion_bigdump') }}');
           
           $('#btnExportar').on('click', function(event) {
               $('#btnExportar').attr('disabled',true);
               $('.bar').animate({
                    width: "100%"
                  }, 1200 , "linear", function() {
                     
                    $('#porciento').text('100%');
                    $('#cartel').text('Gracias!');
                        
              });
           });
           
           $('#btnVolverExportar').on('click', function(event) {
               $('.bar').animate({
                    width: "0%"
                  }, 30 , "linear", function() {
                     
                    $('#porciento').text('0%');
                    $('#cartel').text('Por favor aguarde...');
                    $('#btnExportar').attr('disabled',false);
              });
           });
        
        });
        
        function exportDataBase(path){
            
            window.open(path, '_blank');
                             
            return false;
            
        };
    </script>
{% endblock %}